package com.wuhan.template.module.home.fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.wuhan.template.R;
import com.wuhan.template.base.BaseFragment;
import com.wuhan.template.module.home.adapter.JieMuDanFragmentAdapter;
import com.wuhan.template.utils.EventMessage;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by Administrator on 2016/5/12 0012.
 */
public class JieMuDanFragment extends BaseFragment{

    @BindView(R.id.jiemudan_tablayout)
    protected TabLayout tabLayout;

    @BindView(R.id.jiemudan_viewPage)
    protected ViewPager viewPager;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_jiemudan;
    }

    public JieMuDanFragment() {

    }

    @Override
    protected void initViews() {

        List<Fragment> fragments = new ArrayList<>();

        for (int i = 0; i < 7; i++) {
            fragments.add(JieMuDanDetailFragment.newInstance(i+"",id));
        }

        JieMuDanFragmentAdapter adapter =
                new JieMuDanFragmentAdapter(getChildFragmentManager(),fragments);
        viewPager.setAdapter(adapter);

        tabLayout.setSelectedTabIndicatorColor(Color.BLUE);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
        tabLayout.setupWithViewPager(viewPager);


    }

    @Override
    protected void loadData() {
        super.loadData();
    }

    @Override
    protected void postEventResult(@NonNull EventMessage message) {
        super.postEventResult(message);
    }

    private  String id = "0";
    @Override
    protected void getReqParams(Bundle bundle) {
         id = bundle.getString("id");
    }

}
